home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / admin / sudo-1.000 / sudo-1 / sudo-1.2 / parse.yacc < prev    next >
Text File  |  1993-06-11  |  3KB  |  99 lines

  1. %{
  2. /*
  3.  *  sudo version 1.1 allows users to execute commands as root
  4.  *  Copyright (C) 1991  The Root Group, Inc.
  5.  *
  6.  *  This program is free software; you can redistribute it and/or modify
  7.  *  it under the terms of the GNU General Public License as published by
  8.  *  the Free Software Foundation; either version 1, or (at your option)
  9.  *  any later version.
  10.  *
  11.  *  This program is distributed in the hope that it will be useful,
  12.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.  *  GNU General Public License for more details.
  15.  *
  16.  *  You should have received a copy of the GNU General Public License
  17.  *  along with this program; if not, write to the Free Software
  18.  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19.  *
  20.  *  If you make modifications to the source, we would be happy to have
  21.  *  them to include in future releases.  Feel free to send them to:
  22.  *      Jeff Nieusma                       nieusma@rootgroup.com
  23.  *      3959 Arbol CT                      (303) 447-8093
  24.  *      Boulder, CO 80301-1752             
  25.  */
  26. /*******************************************************************************
  27. * parse.yacc, sudo project
  28. * David R. Hieb
  29. * March 18, 1991
  30. *
  31. * Yacc Specification file for the sudo project.
  32. *******************************************************************************/
  33. #include <stdio.h>
  34. #include "sudo.h"
  35.  
  36. extern int yylineno;
  37. extern int parse_error, found_user;
  38.  
  39. yyerror(s)
  40. char *s;
  41. {
  42. fprintf(stderr, ">>> sudoers file: %s, line %d <<<\n", s, yylineno);
  43. parse_error = TRUE;
  44. }
  45.  
  46. yywrap()
  47. {
  48. return(1);
  49. }
  50. %}
  51.  
  52. %start file                /* special start symbol */
  53. %token <char_val> IDENT1        /* identifier type 1*/
  54. %token <char_val> IDENT2        /* identifier type 2*/
  55. %token <char_val> IDENT3        /* identifier type 3*/
  56. %token <int_val>  COMMENT        /* comment and/or carriage return */
  57. %token <int_val>  ERROR            /* error character(s) */
  58. %token <int_val> ':' '=' ',' '!'    /* union member tokens */
  59. %%
  60. file        :    entry
  61.         |    file entry
  62.         ;
  63.  
  64. entry        :    COMMENT
  65.                 |       error COMMENT
  66.             { yyerrok; }
  67.         |    IDENT1 access_series COMMENT
  68.             { if (call_back(TYPE1, ' ', $1) == FOUND_USER) {
  69.                 found_user = TRUE;
  70.                 return(FOUND_USER);
  71.                 }
  72.               else {
  73.                 found_user = FALSE;
  74.                 } }
  75.         ;
  76.  
  77. access_series    :    access_group
  78.         |    access_series ':' access_group
  79.         ;
  80.  
  81. access_group    :    IDENT2 '=' cmnd_list
  82.             { call_back(TYPE2, ' ', $1); }
  83.         ;
  84.  
  85. cmnd_list    :    cmnd_type
  86.         |    cmnd_list ',' cmnd_type
  87.         ;
  88.  
  89. cmnd_type    :    IDENT3
  90.             { call_back(TYPE3, ' ', $1); }
  91.         |    '!' IDENT3
  92.             { call_back(TYPE3, '!', $2); }
  93.         |    IDENT2
  94.             { call_back(TYPE3, ' ', $1); }
  95.         |    '!' IDENT2
  96.             { call_back(TYPE3, '!', $2); }
  97.         ;
  98. %%
  99.